#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include "myedit.h"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
      long long i = reinterpret_cast<long long>(line_edit_);
      qDebug() << "[初始化]line_edit_: "<< i << Qt::endl;
    ui->setupUi(this);
    line_edit_ = new Myedit(this);
    line_edit_->move(100,100);
    line_edit_->installEventFilter(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::keyPressEvent(QKeyEvent *event)
{
    qDebug() << "Widget::keyPressEvent" << Qt::endl;
    event->ignore();
}

bool Widget::eventFilter(QObject *watched, QEvent *event)
{
    if(watched == line_edit_)
    {
        if(event->type()==QEvent::KeyPress)
        {
            qDebug() << "事件过滤器" << Qt::endl;
            return false;
        }
    }

    return QWidget::eventFilter(watched,event);
}

bool Widget::event(QEvent *e)
{
    if(e->type()==QEvent::KeyPress)
    {
        qDebug() << "Widget::event" << Qt::endl;
        //return false;
    }
    return QWidget::event(e);
}
